/*
 * Copyright (C) 2023 Coder.AN
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#include "udp_img_trans.h"
#include <iostream>


int main(int argc, char* argv[])
{
    UDPImgSender img_sender;

    if (argc != 3)
    {
        std::cout << "usage: demo_img_sender <ip> <port>" << std::endl;
        return 0;
    }

    img_sender.set_target_ip(argv[1]);
    img_sender.set_target_port(atoi(argv[2]));

    if (!img_sender.init())
    {
        std::cout << "Can not init img_sender!" << std::endl;
        return 0;
    }

    cv::Mat img = cv::Mat::zeros(512, 512, CV_8UC3);

    for (int i = 0; i < 10; i++)
    {
        img_sender.send(img);
        std::cout << "send one image." << std::endl;
        usleep(5 * 1000); // 暂停 5ms
    }

    return 0;
}